﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="WorkflowEdit.aspx.cs" Inherits="SaaS.WorkflowEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Add/Edit Workflow</title>
</head>
<body background="https://minisaas.blob.core.windows.net/img/bg.jpg">
    <form id="form1" runat="server">
    <div>
    
        <asp:HyperLink ID="HyperLink1" runat="server" 
            NavigateUrl="~/WorkflowManager.aspx">&lt;- Back</asp:HyperLink>
        <br />
        <br />
        Here you may set the services that belong to your workflow and the order that 
        they will be executed. By default, the output of a function will be the input of 
        the next. You may edit this by clicking the &quot;Edit Data Links...&quot; button. 
        The service with the minimum order number will be the starting service.<br />
        <br />
        <asp:Label ID="lblMode" runat="server" Font-Bold="True" Font-Size="X-Large"></asp:Label>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Workflow ID:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="lblWorkflowID" runat="server"></asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" Text="Workflow Name:"></asp:Label>
&nbsp;
        <asp:Label ID="lblWorkflowName" runat="server"></asp:Label>
        <br />
        <br />
        Search Criteria:
        <asp:TextBox ID="txtSearch" runat="server" Width="150px"></asp:TextBox>
&nbsp;
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Update" />
&nbsp;<asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Clear" />
        <br />
        Show only recommended services:         <asp:RadioButton ID="rdoRecommendedYes" runat="server" AutoPostBack="True" 
            Checked="True" GroupName="recommended" 
            oncheckedchanged="rdoRecommendedYes_CheckedChanged" Text="Yes" />
&nbsp;<asp:RadioButton ID="rdoRecommendedNo" runat="server" AutoPostBack="True" 
            GroupName="recommended" oncheckedchanged="rdoRecommendedNo_CheckedChanged" 
            Text="No" />
        <br />
        <asp:DropDownList ID="ddlService" runat="server" AutoPostBack="True" 
            onselectedindexchanged="ddlService_SelectedIndexChanged1" Width="280px">
        </asp:DropDownList>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            style="margin-left: 17px" Text="Add Service" />
        <br />
        Service Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtServiceName" runat="server" Width="171px" 
            style="margin-left: 15px" Enabled="False"></asp:TextBox>
        <br />
        Service Path:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
        <asp:TextBox ID="txtServicePath" runat="server" Width="171px" 
            style="margin-left: 13px" Enabled="False"></asp:TextBox>
&nbsp;(Begin path with &#39;/&#39; if it is local to site)<br />
        Service Function:&nbsp;&nbsp; &nbsp;&nbsp;         
        <asp:TextBox ID="txtServiceFunction" runat="server" Width="171px" 
            style="margin-left: 16px" Enabled="False" 
            ontextchanged="txtServiceFunc_TextChanged"></asp:TextBox>
        <br />
        Service Description: 
        <asp:TextBox ID="txtServiceDescription" runat="server" Height="78px" 
            Width="170px" TextMode="MultiLine" style="margin-left: 18px" 
            Enabled="False" ontextchanged="txtServiceDesc_TextChanged"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button4" runat="server" PostBackUrl="~/WorkflowLinks.aspx" 
            Text="Edit Data Links..." Visible="False" />
        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="Current Sequence:"></asp:Label>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="Service_ID" ForeColor="#333333" GridLines="None" 
            onrowcommand="GridView1_RowCommand" DataSourceID="SqlDataSource1" 
            Width="921px" onselectedindexchanged="GridView1_SelectedIndexChanged">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:BoundField DataField="Order_Number" HeaderText="Order" 
                    SortExpression="Order_Number" />
                <asp:BoundField DataField="Service_ID" HeaderText="ID" ReadOnly="True" 
                    SortExpression="Service_ID" />
                <asp:BoundField DataField="Service_Name" HeaderText="Name" 
                    SortExpression="Service_Name" />
                <asp:BoundField DataField="Service_Path" HeaderText="Path" 
                    SortExpression="Service_Path" />
                <asp:BoundField DataField="Service_Function_Name" HeaderText="Function Name" 
                    SortExpression="Service_Function_Name" />
                <asp:BoundField DataField="Service_Description" HeaderText="Description" 
                    SortExpression="Service_Description" />
                <asp:ButtonField CommandName="Del" Text="Remove" />
                <asp:ButtonField CommandName="moveUp" Text="Move Up /\" />
                <asp:ButtonField CommandName="moveDown" Text="Move Down \/" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MiniSaaSConnectionString %>" 
            
            SelectCommand="SELECT SERVICE.Service_ID, SERVICE.Service_Name, SERVICE.Service_Path, SERVICE.Service_Function_Name, SERVICE.Service_Description, TENANT_WORKFLOW_SERVICE.Order_Number FROM SERVICE INNER JOIN TENANT_WORKFLOW_SERVICE ON SERVICE.Service_ID = TENANT_WORKFLOW_SERVICE.Service_ID WHERE (TENANT_WORKFLOW_SERVICE.Tenant_Workflow_ID = @workflowid) ORDER BY TENANT_WORKFLOW_SERVICE.Order_Number">
            <SelectParameters>
                <asp:ControlParameter ControlID="lblWorkflowID" DefaultValue="-1" 
                    Name="workflowid" PropertyName="Text" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <asp:Label ID="lblErr" runat="server" ForeColor="Red"></asp:Label>
    </div>
    </form>
</body>
</html>
